package com.base.cn.platform.os.controller.count;

import com.base.cn.platform.os.common.AdminBaseController;
import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.service.exam.count.ExamCountService;
import com.base.cn.platform.os.service.manage.user.count.UserCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * 考试数据统计Controller
 *
 * @author s.li
 * @create 2018-08-24-16:50
 */
@Controller
@RequestMapping("/admin/count")
public class ExamCountStatisticsController extends AdminBaseController {

    @Autowired
    private UserCountService userCountService;
    @Autowired
    private ExamCountService examCountService;

    /**
     * 初始化考试数据统计页面
     * @return
     */
    @RequestMapping("/examCount")
    public String examCount(){
        return resultPage("/count/exam-statistics");
    }

    /**
     * 查询考试数据统计的基本数据统计
     * @return Map<String,Object>
     */
    @RequestMapping("/examBaseCount")
    @ResponseBody
    public Map<String,Object> examBaseCount(){
        Map<String,Object> dataMap = new HashMap<>();
        //用户数量
        Map<String,Integer>  userCountMap = userCountService.findUserCount();
        dataMap.put("userCountMap",userCountMap);
        //试题数据统计
//        Map<String,Integer> examCountMap = examCountService.queryExamCountNum();
        Map<String,Integer> examCountMap = new HashMap<>();
        dataMap.put("examCountMap",examCountMap);

        return ResultUtil.SUCCESS(dataMap);
    }

    /**
     * 易错考点前 10 (综合版)
     * @return
     */
    @RequestMapping("/queryQuestionRecordPointCount")
    @ResponseBody
    public Map<String,Object> queryQuestionRecordPointCount(){
        List<Map<String,Object>> questionRecordPointCountList = examCountService.queryQuestionRecordPointCount();
        return ResultUtil.SUCCESS(questionRecordPointCountList);
    }

    /**
     * 试卷使用排行 前10
     * @return Map<String,Object>
     */
    @RequestMapping("/queryExamRecordCount")
    @ResponseBody
    public Map<String,Object> queryExamRecordCount(){
        List<Map<String,Object>> examRecordCountNumList = examCountService.queryExamRecordCountNum();
        return ResultUtil.SUCCESS(examRecordCountNumList);
    }
}
